/*
 * Copyright 2011 Digia Oyj - Jaakko Purhonen <jaakko.purhonen@digia.com>
 */

#ifndef TRACIMPORTSETTINGSWIDGET_H
#define TRACIMPORTSETTINGSWIDGET_H

#include "xmlrpcrequest.h"
#include "tracsettings.h"
#include <QtGui/QWidget>
#include <QtGui/QLineEdit>
#include <QtCore/QVariant>
namespace XmlRpc {
class XmlRpcConnection;
class XmlRpcResponse;
class XmlRpcRequest;
}

namespace Trac {
namespace Internal {


namespace Ui {
    class TracImportSettingsWidget;
}

class TracImportSettingsWidget : public QWidget
{
    Q_OBJECT

public:
    explicit TracImportSettingsWidget(QWidget *parent = 0);
    ~TracImportSettingsWidget();
    void initialize();
    bool isValid() const;
    const QString currentProjectIdentifier();
    void openProject();

signals:
    void validChanged(bool value);

private slots:
    void browse();
    void checkIsValid();
    void rpcQueryCompleted(XmlRpc::XmlRpcResponse *response);

private:
    Ui::TracImportSettingsWidget *ui;
    bool m_valid;
    XmlRpc::XmlRpcConnection *m_connection;
    XmlRpc::XmlRpcRequest m_request;
    QString m_currentProjectIdentifier;
    void parseSettings(TracSettings *instance, QVariantList values);
    bool validateCloneUrlLineEdit();
    bool validateCheckoutPathChooser();
    bool validateCheckoutDirectoryLineEdit();

};

} // namespace Internal
} // namespace Trac

#endif // TRACIMPORTSETTINGSWIDGET_H
